import re


def f():
    url = "n_v1bj3gzsccvi4vorxycilq.jpg?w=425?&h=320"
    i = url.find("#")
    print(i)
    print(url[0:i])


def f2():
    url = "n_v1bj3gzsccvi4vorxycilq.jpg?w=425?h=320"
    # +? ?非贪婪匹配
    # s = r"(\S+?)\?"
    s = r"(.+?)\?"
    ss = re.findall(s, url)
    print(ss)


# f2()

def f3():
    srs = ["someone@gmail.com", "bill.gates@microsoft.com"]
    r = r"^[a-zA-Z]{1}[\w.]{5,15}@[\w]{2,10}.(com|org|cn)$"
    for s in srs:
        if re.match(r, s):
            print(1)
        else:
            print(0)


def f4():
    srs = ["<Tom Paris> tom@voyager.org", "bob@example.com"]
    # r1 = r"<([\w\s]+)>"
    r1 = r"<([^>]+)>"
    # r2 = r"(\S+?)@"
    r2 = r"([^@]+?)@"
    r3 = r"<([\w\s]+)>|(\S+?)@"
    r4 = r"(\S+?)@|<([\w\s]+)>"
    for s in srs:
        print("###", re.findall(r3, s))
        print("***", re.findall(r4, s))
        if s.startswith("<"):
            print(re.findall(r1, s))
        else:
            print(re.findall(r2, s))


# f4()


def f5():
    srs = "abc123ccc345ddd45678@@@0000...4444pppp343adfasd";
    print(re.findall(r"\d+", srs))
    print(re.findall(r"\D+", srs))

f5()